﻿@{Html.BeginForm();}
<table>
    <tr>
        <td>Name:</td>
        <td><input type="text" id="txtName" /></td>
    </tr>

    <tr>
        <td>Address:</td>
        <td><input type="text" id="txtAddress" /></td>
    </tr>

    <tr>
        <td></td>
        <td><input type="button" id="cmdCreate" value="Create" /></td>
    </tr>

</table>
@{Html.EndForm();}

<script type="text/javascript">

    $(document).ready(function () {
        $("input[id='cmdCreate']").click(OnCreateCustomer);

    });

    var OnCreateCustomer = function () {

        var name = $("input[id='txtName']").val();
        var address = $("input[id='txtAddress']").val();

        $.ajax({ type: "POST",
            url: "/Home/Create",
            data: "Name=" + name + "&Address=" + address,
            success: function (data) {
                window.location.href = "http://" + window.location.host;
            }
        });

    };

</script>